﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using PssFramework;
using PssFramework.PSServer;
namespace PssServerUi
{
    public partial class FormMain : Form
    {
        PssFramework.PSServer.Server server;
        public FormMain()
        {
            InitializeComponent();
            CheckForIllegalCrossThreadCalls = false;
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            server = new PssFramework.PSServer.Server();
            server.OnServerEvent += new EventHandler(server_OnServerEvent);
            server.StartPSS();
            label2.Text=PssFramework.Config.getInstance().HostIp;
            string sum = "Server; IP:" + PssFramework.Config.getInstance().HostIp;
            sum += ", pub port:" + PssFramework.Config.getInstance().PublishPort;
            sum += ", sub port:" + PssFramework.Config.getInstance().SubscribePort; 
            listBox1.Items.Add(sum);
        }

        void server_OnServerEvent(object sender, EventArgs e)
        {
            
            listBox1.Items.Add(((ServerEventArgs)e).mEventData);
            
        }

        private void button1_Click(object sender, EventArgs e)
        {
            PssFramework.PSClient.Publisher pub;
            PssFramework.PSClient.Subscriber sub;
            pub = new PssFramework.PSClient.Publisher();
            sub = new PssFramework.PSClient.Subscriber();
            sub.Subscribe(2);
 
        }

        private void label2_Click(object sender, EventArgs e)
        {
            
        }
    }
}
